package com.csg.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.csg.entity.Game;
import com.csg.entity.Tc;
import com.csg.service.TcService;

@Controller
public class TcController {
	@Autowired
	private TcService tcService;
	/*@RequestMapping("/")
	public String selectAllTc(Model model){			
		List<Tc> list = this.tcService.selectAllTc();		
		model.addAttribute("list", list);		
		return "/new.jsp";
		
	}*/
	@RequestMapping("/shouye")
	public String selectTcByModule(Game game,Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule(module);	
		List<Tc> list2 = this.tcService.selectTcByModule2(module);
		List<Tc> list3 = this.tcService.selectTcByModule3(module);
		List<Tc> list4 = this.tcService.selectTcByModule4(module);
		List<Tc> list5 = this.tcService.selectTcByModule5(module);
		List<Tc> list6 = this.tcService.selectTcByModule6(module);
		List<Tc> list7 = this.tcService.selectTcByModule7(module);
		List<Tc> list8 = this.tcService.selectTcByModule8(module);
		List<Game> result = this.tcService.selectCompitition(game);
		model.addAttribute("list", list);
		model.addAttribute("list2", list2);
		model.addAttribute("list3", list3);
		model.addAttribute("list4", list4);
		model.addAttribute("list5", list5);
		model.addAttribute("list6", list6);
		model.addAttribute("list7", list7);
		model.addAttribute("list8", list8);
		model.addAttribute("Game", result);
		return "/w_index2.jsp";
		
	}
	@RequestMapping("/userShouYe")
	public String selectTcAllUser(Game game,Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule(module);	
		List<Tc> list2 = this.tcService.selectTcByModule2(module);
		List<Tc> list3 = this.tcService.selectTcByModule3(module);
		List<Tc> list4 = this.tcService.selectTcByModule4(module);
		List<Tc> list5 = this.tcService.selectTcByModule5(module);
		List<Tc> list6 = this.tcService.selectTcByModule6(module);
		List<Tc> list7 = this.tcService.selectTcByModule7(module);
		List<Tc> list8 = this.tcService.selectTcByModule8(module);
		List<Game> result = this.tcService.selectCompitition(game);
		model.addAttribute("list", list);
		model.addAttribute("list2", list2);
		model.addAttribute("list3", list3);
		model.addAttribute("list4", list4);
		model.addAttribute("list5", list5);
		model.addAttribute("list6", list6);
		model.addAttribute("list7", list7);
		model.addAttribute("list8", list8);
		model.addAttribute("Game", result);
		return "/w_index3.jsp";
		
	}
	
	@RequestMapping("/selectTcByModule11")
	public String selectTcByModule1(Game game,Model model){			
		List<Game> result = this.tcService.selectTcByModule1(game);		
		model.addAttribute("lists", result);		
		return "/w_module1.jsp";
		
	}	
	@RequestMapping("/selectTcByModule22")
	public String selectTcByModule22(Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule22(module);		
		model.addAttribute("list22", list);		
		return "/w_module2.jsp";
		
	}
	@RequestMapping("/selectTcByModule33")
	public String selectTcByModule33(Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule33(module);		
		model.addAttribute("list33", list);		
		return "/w_module3.jsp";
		
	}
	@RequestMapping("/selectTcByModule44")
	public String selectTcByModule44(Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule44(module);		
		model.addAttribute("list44", list);		
		return "/w_module4.jsp";
		
	}
	@RequestMapping("/selectTcByModule55")
	public String selectTcByModule55(Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule55(module);		
		model.addAttribute("list55", list);		
		return "/w_module5.jsp";
		
	}
	@RequestMapping("/selectTcByModule66")
	public String selectTcByModule66(Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule66(module);		
		model.addAttribute("list66", list);		
		return "/w_module6.jsp";
		
	}
	@RequestMapping("/selectTcByModule77")
	public String selectTcByModule77(Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule77(module);		
		model.addAttribute("list77", list);		
		return "/w_module7.jsp";
		
	}
	@RequestMapping("/selectTcByModule88")
	public String selectTcByModule88(Integer module,Model model){			
		List<Tc> list = this.tcService.selectTcByModule88(module);		
		model.addAttribute("list88", list);		
		return "/w_module8.jsp";
		
	}
	
	
	
	@RequestMapping("selectTcById")
	public String selectTcById(int id,Model model){
		
		Tc tc = this.tcService.selectTcById(id);
		
		model.addAttribute("tc", tc);
		return "/w_article.jsp";
		
	}
	
	
	
	@RequestMapping("toUpdateGame")
	public String toUpdateGame(Integer id,Model model){
		
		Game tuc = this.tcService.selectGameById(id);
		model.addAttribute("tuc", tuc);
		return "/w_update.jsp";
		
	}
	@RequestMapping("toUpdateTc2")
	public String toUpdateTc2(Integer id,Model model){
		
		Tc tuc = this.tcService.selectTcById(id);
		model.addAttribute("tuc", tuc);
		return "/w_update2.jsp";
		
	}
	@RequestMapping("toUpdateTc3")
	public String toUpdateTc3(Integer id,Model model){
		
		Tc tuc = this.tcService.selectTcById(id);
		model.addAttribute("tuc", tuc);
		return "/w_update3.jsp";
		
	}
	@RequestMapping("toUpdateTc4")
	public String toUpdateTc4(Integer id,Model model){
		
		Tc tuc = this.tcService.selectTcById(id);
		model.addAttribute("tuc", tuc);
		return "/w_update4.jsp";
		
	}
	@RequestMapping("toUpdateTc5")
	public String toUpdateTc5(Integer id,Model model){
		
		Tc tuc = this.tcService.selectTcById(id);
		model.addAttribute("tuc", tuc);
		return "/w_update5.jsp";
		
	}
	@RequestMapping("toUpdateTc6")
	public String toUpdateTc6(Integer id,Model model){
		
		Tc tuc = this.tcService.selectTcById(id);
		model.addAttribute("tuc", tuc);
		return "/w_update6.jsp";
		
	}
	@RequestMapping("toUpdateTc7")
	public String toUpdateTc7(Integer id,Model model){
		
		Tc tuc = this.tcService.selectTcById(id);
		model.addAttribute("tuc", tuc);
		return "/w_update7.jsp";
		
	}
	@RequestMapping("toUpdateTc8")
	public String toUpdateTc8(Integer id,Model model){
		
		Tc tuc = this.tcService.selectTcById(id);
		model.addAttribute("tuc", tuc);
		return "/w_update8.jsp";
		
	}
	
	@RequestMapping("doUpdateGame")
	public String updateGame(Game game){
		
		boolean result = this.tcService.updateGame(game);
		if(result){
			return "forward:selectTcByModule11";
		}
		return "/w_update.jsp";
			
		
	}
	@RequestMapping("doUpdateTc2")
	public String updateTc2(Tc tc){
		
		boolean result = this.tcService.updateTc(tc);
		if(result){
			return "forward:selectTcByModule22";
		}
		return "/w_update2.jsp";
			
		
	}
	@RequestMapping("doUpdateTc3")
	public String updateTc3(Tc tc){
		
		boolean result = this.tcService.updateTc(tc);
		if(result){
			return "forward:selectTcByModule33";
		}
		return "/w_update3.jsp";
			
		
	}
	@RequestMapping("doUpdateTc4")
	public String updateTc4(Tc tc){
		
		boolean result = this.tcService.updateTc(tc);
		if(result){
			return "forward:selectTcByModule44";
		}
		return "/w_update4.jsp";
			
		
	}
	@RequestMapping("doUpdateTc5")
	public String updateTc5(Tc tc){
		
		boolean result = this.tcService.updateTc(tc);
		if(result){
			/*return "forward:selectTcByModule55";*/
			System.out.println("修改成功");
		}
		return "forward:selectTcByModule55";
			
		
	}
	@RequestMapping("doUpdateTc6")
	public String updateTc6(Tc tc){
		
		boolean result = this.tcService.updateTc(tc);
		if(result){
			/*return "forward:selectTcByModule66";*/
			System.out.println("修改成功");
		}
		return "forward:selectTcByModule66";
			
		
	}
	@RequestMapping("doUpdateTc7")
	public String updateTc7(Tc tc){
		
		boolean result = this.tcService.updateTc(tc);
		if(result){
			return "forward:selectTcByModule77";
		}
		return "/w_update7.jsp";
			
		
	}
	@RequestMapping("doUpdateTc8")
	public String updateTc8(Tc tc){
		
		boolean result = this.tcService.updateTc(tc);
		if(result){
			return "forward:selectTcByModule88";
		}
		return "/w_update8.jsp";
			
		
	}
	@RequestMapping("deleteGame")
	public String deleteGame(Integer id){
		
		boolean result = this.tcService.deleteGame(id);
		if(result){
			System.out.println("删除成功");
		}
		return "forward:selectTcByModule11";
			
	}
	@RequestMapping("deleteTc2")
	public String deleteTc2(Integer id){
		
		boolean result = this.tcService.deleteTc(id);
		if(result){
			System.out.println("删除成功");
		}
		return "forward:selectTcByModule22";
			
	}
	@RequestMapping("deleteTc3")
	public String deleteTc3(Integer id){
		
		boolean result = this.tcService.deleteTc(id);
		if(result){
			System.out.println("删除成功");
		}
		return "forward:selectTcByModule33";
			
	}
	@RequestMapping("deleteTc4")
	public String deleteTc4(Integer id){
		
		boolean result = this.tcService.deleteTc(id);
		if(result){
			System.out.println("删除成功");
		}
		return "forward:selectTcByModule44";
			
	}
	@RequestMapping("deleteTc5")
	public String deleteTc5(Integer id){
		
		boolean result = this.tcService.deleteTc(id);
		if(result){
			System.out.println("删除成功");
		}
		return "forward:selectTcByModule55";
			
	}
	@RequestMapping("deleteTc6")
	public String deleteTc6(Integer id){
		
		boolean result = this.tcService.deleteTc(id);
		if(result){
			System.out.println("删除成功");
		}
		return "forward:selectTcByModule66";
			
	}
	@RequestMapping("deleteTc7")
	public String deleteTc7(Integer id){
		
		boolean result = this.tcService.deleteTc(id);
		if(result){
			System.out.println("删除成功");
		}
		return "forward:selectTcByModule77";
			
	}
	@RequestMapping("deleteTc8")
	public String deleteTc8(Integer id){
		
		boolean result = this.tcService.deleteTc(id);
		if(result){
			System.out.println("删除成功");
		}
		return "forward:selectTcByModule88";
			
	}
	
	@RequestMapping("addGame")
	public String addGame(Game game){		
		boolean result = this.tcService.addGame(game);
		if(result){
			System.out.println("添加成功");
		}
		return "forward:selectTcByModule11";
				
	}
	@RequestMapping("addTc2")
	public String addTc2(Tc tc){		
		boolean result = this.tcService.addTc(tc);
		if(result){
			System.out.println("添加成功");
		}
		return "forward:selectTcByModule22";
				
	}
	@RequestMapping("addTc3")
	public String addTc3(Tc tc){		
		boolean result = this.tcService.addTc(tc);
		if(result){
			System.out.println("添加成功");
		}
		return "forward:selectTcByModule33";
				
	}
	@RequestMapping("addTc4")
	public String addTc4(Tc tc){		
		boolean result = this.tcService.addTc(tc);
		if(result){
			System.out.println("添加成功");
		}
		return "forward:selectTcByModule44";
				
	}
	@RequestMapping("addTc5")
	public String addTc5(Tc tc){		
		boolean result = this.tcService.addTc(tc);
		if(result){
			System.out.println("添加成功");
		}
		return "forward:selectTcByModule55";
				
	}
	@RequestMapping("addTc6")
	public String addTc6(Tc tc){		
		boolean result = this.tcService.addTc(tc);
		if(result){
			System.out.println("添加成功");
		}
		return "forward:selectTcByModule66";
				
	}
	@RequestMapping("addTc7")
	public String addTc7(Tc tc){		
		boolean result = this.tcService.addTc(tc);
		if(result){
			System.out.println("添加成功");
		}
		return "forward:selectTcByModule77";
				
	}
	@RequestMapping("addTc8")
	public String addTc8(Tc tc){		
		boolean result = this.tcService.addTc(tc);
		if(result){
			System.out.println("添加成功");
		}
		return "forward:selectTcByModule88";
				
	}
	
	
}
